package me.algo.lst;

import java.util.Objects;

/**
 * @author guozheng
 * @date 2024/4/28
 */
public class L7 {
    public static void main(String[] args) {

    }

    public static ListNode middleNode(ListNode head) {
        if (Objects.isNull(head)) {
            return null;
        }
        ListNode fast = head;
        ListNode slow = head;
        while (fast != null && fast.next != null) {
            fast = fast.next.next;
            slow = slow.next;
        }
        return slow;
    }
}
